
class Person{
    constructor(_name,_age){
        this.name = _name ;
        this.age = _age ;
    }
    introduce(){
        return `My name is ${this.name}. I am ${this.age} years old.` ;
    }
}
module.exports = Person ;
class Class{
    constructor(_number){
        this.number = _number ;
    }
}
class Student extends Person{
    constructor(_name,_age,_klass){
        super(_name,_name) ;
        this.klass = _klass;
    }
    intorduce(){
        return super.intorduce() + ` I am a Student. I am at Class ${this.klass.number}.`
    }
}
class Teacher extends Person{
    constructor(_name,_age,_klass){
        super(_name,_age);
        this.klass = _klass ;
    }
    introduce(){
        if(this.klass){
            return super.introduce() + ` I am a Teacher. I teach Class ${this.klass.number}.` ;
        }else{
            return super.introduce() + ` I am a Teacher. I teach No Class.` ;
        }
    }
    introduceWith(_student){
        if(_student.klass.number === this.klass.number){
            return super.introduce() + ` I am a Teacher. I teach ${_student.name}.`;  
        }else{
            return super.introduce() + ` I am a Teacher. I don't teach ${_student.name}.` ;
        }
    }
}
// let klass =new  Class(2);
// let s1 = new Student("Tom",16,new Class(12));
// let t1 = new Teacher("zhuzi",42,klass);
// console.log(t1.introduceWith(s1));

